﻿using System;
using System.Collections;
using System.Reflection;
using System.Text;
using System.Xml.Linq;
using RkCalendar.Properties;
using RkCalendar.ViewModel;

namespace RkCalendar
{
    internal class Program
    {
        private static string GetSplitLine(string text, int cont, string color)
        {
            string line = string.Join("", Enumerable.Repeat(text, cont));
            if(!string.IsNullOrEmpty(color))
                line = color + line + "{/}";
            return line;
        }
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            var time = DateTime.Now;
            CalendarViewModel calendarView = new CalendarViewModel(time)
            {
                IsSundayFirst = false
            };

            ConsoleWriter.WriteLine(GetSplitLine("——",30,"{+Magenta}"));
            
            var infos = calendarView.GetCurrentDayAlmanacInfo();
            foreach(var info in infos) 
            {
                ConsoleWriter.WriteLine(info);
            }

            ConsoleWriter.WriteLine(GetSplitLine("——",30,"{+Magenta}"));

            var texts = calendarView.GetCalendarTexts();
            for(int i = 0; i < texts.GetLength(0); i++)
            {
                ConsoleWriter.Write("|");
                for(int j=0; j < texts.GetLength(1); j++)
                {
                    var text = texts[i,j];
                    ConsoleWriter.Write(text.Text, text.BackColor, text.ForeColor);
                    ConsoleWriter.Write("|");
                }
                ConsoleWriter.WriteLine("");
            }
        }
    }
}